#include "mywidget.h"
#include "ui_mywidget.h"
#include "info.h"

myWidget::myWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::myWidget)
{
    ui->setupUi(this);
    //登陆框顶部样式
    ui->label_4->setStyleSheet("background-image: url(:/images/images/bg.png);font: 34pt '微软雅黑';");
    //禁止改变大小
    setMinimumSize(410,300);
    setMaximumSize(410,300);
    //设置窗口标题
    setWindowTitle("ZZU成绩查询系统0.3");
    //设置默认下拉选项
    ui->comboBox->setCurrentIndex(2);

}

myWidget::~myWidget()
{
    delete ui;
}



//登陆按钮
void myWidget::on_pushButton_clicked()
{
    if((ui->lineEdit->text() ==NULL )|(ui->lineEdit_2->text() ==NULL))
    {
        QMessageBox::warning(this,tr("警告"),tr("学号或者密码不能为空!"));
    }else{
        close();
        Info stuInfo(this);   //窗口传值,需要用到this指针
        stuInfo.exec();
    }
}

//返回当前选择操作方对应的链接
QString myWidget::currentSelect()
{
    QString selec;
    switch(ui->comboBox_2->currentIndex())
    {
    case 0:selec="http://jw.zzu.edu.cn/scripts/qscore.dll/search";break;
    case 1:selec="http://jw.zzu.edu.cn/scripts/stuinfo.dll/check";break;
    case 2:selec="http://jw.zzu.edu.cn/scripts/newxkxt.dll/newlogin";break;
    case 3:selec="http://jw.zzu.edu.cn/pks/pkisapi2.dll/kbofstu";break;
    }

  //  qDebug()<<selec;
    return selec;
}

//提交字符串
QString myWidget::postString()
{
    QByteArray postString("nianji=");
    postString.append(ui->comboBox->currentText());
    postString.append("&xuehao=");
    postString.append(ui->lineEdit->text());
    postString.append("&mima=");
    postString.append(ui->lineEdit_2->text());

 //   qDebug()<<postString;
    return postString;
}

QString myWidget::select()
{
    if(ui->comboBox_2->currentText() =="成绩查询")
    {
        return "0";
    }else if(ui->comboBox_2->currentText() =="学生信息")
    {
        return "1";
    }else if(ui->comboBox_2->currentText() =="选课系统")
    {
        return "2";
    }else
    {
        return "3";
    }
}


void myWidget::on_comboBox_2_activated()
{
    currentSelect();
}

void myWidget::open ()
{
    QMessageBox::warning (this,tr("111"),tr("222"));
}
void myWidget::save()
{
    QMessageBox::information(this,tr("qqqq"),tr("bbbb"));
}
